package kr.couponplay.android.activity.search;

import kr.couponplay.android.AppContext;
import android.annotation.SuppressLint;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

@SuppressLint("HandlerLeak") 
public class SearchButtonOnClickListener implements OnClickListener, OnEditorActionListener, OnFocusChangeListener {
	private SearchActivity activity;
	
	public SearchButtonOnClickListener(SearchActivity activity) {
		this.activity = activity;
	}
	
	@Override
	public void onClick(View view) {
//		SearchSubMenuHelper.drawSelectButton(view);
		activity.goSearch();
		AppContext.isClearSearchDeals = true;
	}

	@Override
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		activity.goSearch();
		AppContext.isClearSearchDeals = true;
		return true;
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		if (hasFocus) {
			activity.searchListViewPager.setCurrentItem(0);
		}
	}
}
